<?php

namespace App\System\Base\Repositories;

use App\System\Base\Helpers\Traits\SinglePattern;
use App\System\Base\Model\BaseHoliday;

class BaseHolidayRepository extends Repository
{
    use SinglePattern;

    /**
     * 获取列表
     * @param string $keyword
     * @return mixed
     */
    public function getList()
    {
        $data = BaseHoliday::with(['admin'])->orderBy('id', 'asc')
            ->paginate();
        return $data;
    }

    /**
     * 添加节假日
     * @param $data array 要添加的数据
     */
    public function addData($data)
    {
        return BaseHoliday::insertGetId($data);
    }
    /**
     * 删除节假日
     * @param $id
     */
    public function deleteData($id)
    {
        if(!$id) return false;
        return BaseHoliday::where('id',$id)->delete();
    }

    /**
     *根据日期查询一条记录
     */
    public function getOne($date)
    {
      return BaseHoliday::where('holiday',$date)->first();
    }
}